<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<style type="text/css">
</style>
		<script type="text/javascript">
			$(function() {
				$("form").Validform({
					ajaxPost : true,
					tiptype : ValidUtils.siblingTip,
					callback : function(data) {
						helper.showMsg(data, {
							okHandler : function() {
								location = "../log/viewLogByTime?id=" + data.id;
							}
						});
					}
				});

				$("#name").change(
						function() {
							$("#nameCheck").empty();
							var v = $(this).val();
							if (v.length > 1) {
								var url = "../student/doCheckStudentName";
								$.post(url, {
									name : v
								}, function(data) {
									if (data.success) {
										var html = [ '<div class="dropdown">', '<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">',
												'同名的学员<span class="caret"></span>', '</a>', '<ul class="dropdown-menu">' ];

										for ( var i = 0; i < data.students.length; i++) {
											var student = data.students[i];
											var li = [ '<li><a target="listStudent" href="../log/viewLogByTime?id=', student.id, '">', student.name, '(', student.mobile, ')</a>',
													'</li>', ];

											html = html.concat(li);
										}

										html.push('</ul>');
										html.push('</div>');

										var aEle = $(html.join(''));
										$("#nameCheck").append(aEle);
									}
								});
							}
						});

				$("#mobile").change(
						function() {
							$("#mobileCheck").empty();
							var v = $(this).val();
							if (v.length > 1) {
								var url = "../student/doCheckMobile";
								$.post(url, {
									mobile : v
								}, function(data) {
									if (data.success) {
										var html = [ '<div class="dropdown">', '<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">',
												'同号码用户<span class="caret"></span>', '</a>', '<ul class="dropdown-menu">' ];

										for ( var i = 0; i < data.students.length; i++) {
											var student = data.students[i];
											var li = [ '<li><a target="listStudent" href="../log/viewLogByTime?id=', student.id, '">', student.name, '(', student.mobile, ')</a>',
													'</li>', ];

											html = html.concat(li);
										}

										html.push('</ul>');
										html.push('</div>');

										var aEle = $(html.join(''));
										$("#mobileCheck").append(aEle);
									}
								});
							}
						});

			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<ul class="breadcrumb">
			<li><s:url action="listStudent" namespace="/student" id="listStudent">
				</s:url> <a href="${listStudent}">学员管理</a> <span class="divider">/</span></li>
			<li class="active">创建学员</li>
		</ul>
		<form class="form-horizontal" action="doCreateStudent">
			<fieldset>
				<legend>学员登记</legend>
				<div class="row-fluid">
					<div class="span6">
						<div class="control-group">
							<label class="control-label">内部编号</label>
							<div class="controls">
								<input type="text" name="no" value="${no}" readonly="readonly">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">学号</label>
							<div class="controls">
								<input type="text" name="stuId" value="" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">姓名</label>
							<div class="controls">
								<input type="text" name="name" id="name" value=""> <span id="nameCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">性别</label>
							<div class="controls">
								<label class="radio">
									男<input type="radio" name="sex" value="Male" />
								</label>
								<label class="radio">
									女<input type="radio" name="sex" value="Female" />
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">职业</label>
							<div class="controls">
								<input type="text" name="job" /><span></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">年龄</label>
							<div class="controls">
								<select name="age">
									<option value="0">未设置</option>
									<s:iterator begin="1" end="100" var="age">
										<option value="${age}">${age}</option>
									</s:iterator>
								</select><span id="nameCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">教育程度</label>
							<div class="controls">
								<select name="education">
									<option value="">未设置</option>
									<option>学龄前</option>
									<option>小学</option>
									<optgroup label="中等教育">
										<option>初中</option>
										<option>高中</option>
										<option>中职</option>
										<option>职高</option>
										<option>技校</option>
									</optgroup>
									<optgroup label="高等教育">
										<option>专科</option>
										<option>本科</option>
										<option>硕士研究生</option>
										<option>博士研究生</option>
									</optgroup>
								</select> <span id="nameCheck"></span>
							</div>
						</div>
					</div>
					<div class="span6">
						<div class="control-group">
							<label class="control-label">移动电话</label>
							<div class="controls">
								<input type="text" name="mobile" value="" id="mobile" /> <span id="mobileCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">固定电话</label>
							<div class="controls">
								<input type="text" name="phone" value="" /> <span id="nameCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">电子邮箱</label>
							<div class="controls">
								<input type="text" name="email" value="" /> <span id="nameCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">邮政编码</label>
							<div class="controls">
								<input type="text" name="zip" value="" /> <span id="nameCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">详细地址</label>
							<div class="controls">
								<textarea name="address"></textarea>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">备注</label>
							<div class="controls">
								<textarea name="title"></textarea>
							</div>
						</div>
					</div>
				</div>
			</fieldset>
			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn btn-primary">提交</button>
				</div>
			</div>
		</form>
	</tiles:putAttribute>
</tiles:insertDefinition>